import request from '@/utils/requestH2'

/* 购货单 */

// 获取购货单列表
export function selBuyGoodsListApi(params) {
  return request({
    url: '/buyGoods/selBuyGoodsList',
    method: 'GET',
    params
  })
}

// 新增购货单
export function addBuyGoodsoApi(data) {
  return request({
    url: "/buyGoods/addBuyGoods",
    method: "POST",
    data,
  });
}

// 根据id修改购货单
export function updateBuyGoodsByIdApi(id,data) {
  return request({
    url: `/buyGoods/updateBuyGoodsById/${id}`,
    method: 'PUT',
    data
  })
}

// 根据ids删除购货单
export function delBuyGoodsByIdApi(id) {
  return request({
    url: `/buyGoods/delBuyGoodsById/${id}`,
    method: 'DELETE'
  })
}

// 根据id处理购货单
export function updateBuyGoodsStatusByIdApi(data) {
  return request({
    url: `/buyGoods/updateBuyGoodsStatusById/${data.id}`,
    method: 'PUT',
    data
  })
}

/* 入库单 */

// 获取入库单列表
export function selEnterWarehouseListApi(params) {
  return request({
    url: '/buyGoods/selEnterWarehouseList',
    method: 'GET',
    params
  })
}

// 新增入库单
export function addEnterWarehouseApi(data) {
  return request({
    url: '/buyGoods/addEnterWarehouse',
    method: 'POST',
    data
  })
}

// 根据id修改入库单
export function updateEnterWarehouseByIdApi(data) {
  return request({
    url: `/buyGoods/updateEnterWarehouseById/${data.id}`,
    method: 'PUT',
    data: {
      directorId: data.directorId,
      goodsId: data.goodsId,
      number: data.number,
      operatorId: data.operatorId,
      remark: data.remark,
      totalPrice: data.totalPrice,
      unitPrice: data.unitPrice,
      warehouseId: data.warehouseId
    }
  })
}

// 根据ids删除入库单
export function delEnterWarehouseByIdApi(id) {
  return request({
    url: `/buyGoods/delEnterWarehouseById/${id}`,
    method: 'PUT'
  })
}

// 根据id处理入库单
export function updateEnterWarehouseStatusByIdApi(data) {
  return request({
    url: `/buyGoods/updateEnterWarehouseStatusById/${data.id}`,
    method: 'PUT',
    data: {
      operatorId: data.operatorId, // 操作人id
      remark: data.remark // 备注
    }
  })
}

/* 出库单 */

// 获取出库单列表
export function selOutWarehouseListApi(params) {
  return request({
    url: '/buyGoods/selOutWarehouseList',
    method: 'GET',
    params
  })
}

// 新增出库单
export function addOutWarehouseApi(data) {
  return request({
    url: '/buyGoods/addOutWarehouse',
    method: 'POST',
    data
  })
}

// 根据id修改出库单
export function updateOutWarehouseByIdApi(data) {
  return request({
    url: `/buyGoods/updateOutWarehouseById/${data.id}`,
    method: 'PUT',
    data: {
      customerId: data.customerId, // 客户id
      directorId: data.directorId, // 负责人id
      goodsId: data.goodsId, // 商品id
      number: data.number, // 数量
      operatorId: data.operatorId, // 操作人id
      remark: data.remark, // 备注
      totalPrice: data.totalPrice, // 总价
      unitPrice: data.unitPrice, // 单价
      warehouseId: data.warehouseId // 仓库id
    }
  })
}

// 根据ids删除出库单
export function delOutWarehouseByIdApi(id) {
  return request({
    url: `/buyGoods/delOutWarehouseById/${id}`,
    method: 'PUT'
  })
}

// 根据id处理出库单
export function updateOutWarehouseStatusByIdApi(data) {
  return request({
    url: `/buyGoods/updateOutWarehouseStatusById/${data.id}`,
    method: 'PUT',
    data: {
      operatorId: data.operatorId, // 操作人id
      remark: data.remark // 备注
    }
  })
}

